package kr.ac.kd.handler;

import java.util.HashMap;

import kr.ac.kd.IHandler;
import kr.ac.kd.ServerResponse;


public abstract class AbstractBizHandler implements IHandler{

	private String ip;
	private String port;

	public ServerResponse send(String ip, String port, String id, HashMap<String, Object> collection) {

		this.ip = ip;
		this.port = port;
		setupUrl(id, collection);
		System.out.println("URL : " + collection.get("URL"));
		ServerResponse resp = DataHandler.send(id, collection);
		return doBiz(resp);
	}

	private void setupUrl(String id, HashMap<String, Object> collection) {
		Object urlObj = collection.get("URL");
		if (urlObj == null) collection.put("URL", "http://"+this.ip+":"+this.port+"/DataBroker");		
	}

	abstract public ServerResponse doBiz(ServerResponse resp);

}
